package com.aglhz.nature.utils;

import android.os.Handler;
import android.os.Message;
import android.widget.Button;

public class CheckNumberThread implements Runnable{
	private Button register_get_number;
	
	public CheckNumberThread(Button register_get_number) {
		this.register_get_number=register_get_number;
	}
	Handler handler =new Handler(){

		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			register_get_number.setText(numberTime+"s后再获取");
			
			if (numberTime==0) {
				register_get_number.setText("获取验证码");
				register_get_number.setEnabled(true);
				numberTime=60;
			}
		
		}
		
	};
	 private int numberTime=60;//验证码倒计时
	
	@Override
	public void run() {
		try {
			while (numberTime>0) {
				Thread.sleep(1000);
				numberTime--;
				handler.sendMessage(new Message());
			}
			
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
	}

	
}
